package com.example.demodb.service;

import com.example.demodb.entity.RecoveryKnowledge;
import com.example.demodb.repository.IRecoveryKnowledgeRepository;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecoveryKnowledgeService { //service可以抽象成接口
    @Resource
    private IRecoveryKnowledgeRepository recoveryKnowledgeRepository;
    public void update(RecoveryKnowledge recoveryKnowledge){
        recoveryKnowledgeRepository.save(recoveryKnowledge);//覆盖
    }
    public void delete(Long id){
         recoveryKnowledgeRepository.deleteById(id);
    }
    public List<RecoveryKnowledge> findAll(){
        return recoveryKnowledgeRepository.findAll();
    }
    public List<RecoveryKnowledge> findAllByCategory(Integer c){
        return recoveryKnowledgeRepository.findAllByCategory(c);
    }
    public RecoveryKnowledge add(RecoveryKnowledge recoveryKnowledge){
        return recoveryKnowledgeRepository.save(recoveryKnowledge);
    }

}
